package com.example.springboot.service.imp;

import com.example.springboot.bean.TSCourse;
import com.example.springboot.repository.CourseRepository;
import com.example.springboot.service.CourseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by tang on 2017/11/16.
 */
@Service
public class CourseServiceImp implements CourseService {

    @Resource
    CourseRepository courseRepository;

    @Override
    @Transactional
    public void save(TSCourse course) {
        courseRepository.save(course);

    }

    @Override
    @Transactional
    public void delect(int id) {
        courseRepository.delete(id);

    }

    @Override
    @Transactional
    public void update(TSCourse course) {
          courseRepository.save(course);
    }

    @Override
    @Transactional
    public Iterable<TSCourse> getAll() {
        Iterable<TSCourse> tsCourses=courseRepository.findAll();
        return tsCourses;
    }
}
